//
//  ReviewTableViewCell.m
//  A_Comic
//
//  Created by sos on 16/1/19.
//  Copyright © 2016年 sos. All rights reserved.
//

#import "ReviewTableViewCell.h"

@implementation ReviewTableViewCell

- (void)dealloc
{
    [_qqImage release];
    [_labelOne release];
    [_labelTwo release];
    [_labelThree release];
    [_labelFour release];
    [_labelFir release];
    [_imgOne release];
    [_imgTwo release];
    [super dealloc];
    
    
    
    
    
    
    
}



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        self.qqImage = [[UIImageView alloc]init];
//        self.qqImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.qqImage];
        [self.qqImage release];
        
        self.labelOne = [[UILabel alloc]init];
//        self.label1.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:self.labelOne];
        [self.labelOne release];
        
        self.labelTwo = [[UILabel alloc]init];
//        self.labelTwo.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:self.labelTwo];
        [self.labelTwo release];
        
        self.labelThree = [[UILabel alloc]init];
//        self.labelThree.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:self.labelThree];
        [self.labelThree release];
        
        self.imgOne = [[UIImageView alloc]init];
        self.imgOne.backgroundColor = [UIColor brownColor];
        [self.contentView addSubview:self.imgOne];
        [self.imgOne release];
        
        
        
        self.labelFour = [[UILabel alloc]init];
//        self.labelFour.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:self.labelFour];
        [self.labelFour release];
        
        self.imgTwo = [[UIImageView alloc]init];
        self.imgTwo.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:self.imgTwo];
        [self.imgTwo release];
        
        self.labelFir = [[UILabel alloc]init];
//        self.labelFir.backgroundColor = [UIColor purpleColor];
        [self.contentView addSubview:self.labelFir];
        [self.labelFir release];
        
        
        
        
        
    }
    
    return self;
    
    
}

-(void)layoutSubviews
{
    
    [super layoutSubviews];
    self.qqImage.frame = CGRectMake(10, 10, self.contentView.frame.size.height/9+5, 30);
    self.qqImage.layer.cornerRadius = self.contentView.frame.size.height/18+2.5;
    self.qqImage.clipsToBounds = YES;
    
    self.labelOne.frame = CGRectMake(self.qqImage.frame.origin.x+self.qqImage.frame.size.width+5, self.qqImage.frame.origin.y, 40, self.qqImage.frame.size.height/2+3);
    
    self.labelOne.numberOfLines = 1;
    [self.labelOne sizeToFit];
    
    self.labelTwo.frame = CGRectMake(self.labelOne.frame.origin.x, self.labelOne.frame.origin.y+self.labelOne.frame.size.height, self.contentView.frame.size.width/6, self.qqImage.frame.size.height-self.labelOne.frame.size.height);
    
    self.labelTwo.font = [UIFont systemFontOfSize:14];
    self.labelTwo.textColor = [UIColor grayColor];
    self.labelTwo.numberOfLines = 1;
    [self.labelTwo sizeToFit];
    
    self.imgOne.frame = CGRectMake(self.contentView.frame.size.width/2+self.qqImage.frame.size.width, self.qqImage.frame.origin.y+5, 20, 20);
    
    self.labelThree.frame = CGRectMake(self.imgOne.frame.origin.x+self.imgOne.frame.size.width+10, self.imgOne.frame.origin.y, self.imgOne.frame.size.width*2, self.imgOne.frame.size.height);
    
    self.imgTwo.frame = CGRectMake(self.labelThree.frame.origin.x+self.labelThree.frame.size.width+10, self.labelThree.frame.origin.y, self.imgOne.frame.size.width, self.imgOne.frame.size.height);
    
    
    
    self.labelFour.frame = CGRectMake(self.imgTwo.frame.origin.x+self.imgTwo.frame.size.width+10, self.imgOne.frame.origin.y, self.labelThree.frame.size.width, self.labelThree.frame.size.height);
    
    
    CGFloat h = [[self class] heightWihtText:self.labelFir.text FontOfSize:16];
    self.labelFir.frame = CGRectMake(self.labelOne.frame.origin.x, self.labelTwo.frame.origin.y+self.labelTwo.frame.size.height+10, self.imgTwo.frame.origin.x, h);
    
    self.labelFir.font = [UIFont systemFontOfSize:16];
    self.labelFir.numberOfLines = 0;
    
}
+ (CGFloat)heightWihtText:(NSString *)text FontOfSize:(CGFloat)size
{
    if (text != NULL) {
        // 1.文本属性
        NSDictionary *dic = @{NSFontAttributeName: [UIFont systemFontOfSize:size]};
        // 2.预计尺寸
        CGSize s = CGSizeMake(375 - 20, 1000);
        // 3.计算
        CGRect r = [text boundingRectWithSize:s options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
        return r.size.height;
    } else {
        return 0;
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
